package com.umerclass.ui.action.adapter;

import android.content.Context;
import android.net.Uri;
import android.view.View;
import android.widget.TextView;
import com.bumptech.glide.RequestManager;
import com.facebook.drawee.view.SimpleDraweeView;
import com.shehuan.niv.NiceImageView;
import com.umerclass.R;
import com.umerclass.bean.action.HuoDongBean;
import com.umerclass.frame.ui.recycleview.PullLoadMoreRecyclerView;
import com.umerclass.frame.ui.recycleview.adapter.RecyclerviewBasicPageAdapterTwo;
import com.umerclass.frame.ui.recycleview.base.ViewHolder;
import com.umerclass.frame.ui.recycleview.listener.DataStateListener;
import com.umerclass.frame.ui.recycleview.listener.OptListener;
import com.umerclass.utils.Constants;

public class ActionAdapter extends RecyclerviewBasicPageAdapterTwo<HuoDongBean> {

    private OptListener optListener;
    private RequestManager glideRequestManager;

    public ActionAdapter(Context context, int layoutId) {
        super(context, layoutId);
    }

    public ActionAdapter(Context context, int layoutId,
                         PullLoadMoreRecyclerView pullLoadMoreRecyclerView,
                         DataStateListener dataStateListener, OptListener optListener) {
        super(context, layoutId, pullLoadMoreRecyclerView, dataStateListener);
        this.optListener = optListener;
    }

    public ActionAdapter(Context context, RequestManager glideRequestManager,int layoutId,
                         PullLoadMoreRecyclerView pullLoadMoreRecyclerView,
                         DataStateListener dataStateListener, OptListener optListener) {
        super(context, layoutId, pullLoadMoreRecyclerView, dataStateListener);
        this.optListener = optListener;
        this.glideRequestManager = glideRequestManager;
    }

    @Override
    public void convert(ViewHolder holder, HuoDongBean bean, final int position) {
        SimpleDraweeView imageView = holder.getView(R.id.simpleDraweeView);
        TextView tv_name = holder.getView(R.id.tv_name);
        TextView tv_baoming = holder.getView(R.id.tv_baoming);
        tv_baoming.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                optListener.onOptClick(v,optListener);
            }
        });
        String url = bean.getPath();
        imageView.setImageURI(Uri.parse(url));
        /*glideRequestManager
                //.load(Constants.IP_PORT_DEFAULT_PICTURE + customerProjectBean.getFilePath())
                .load(bean.getPath())
                .placeholder(R.drawable.default_pic)
                .error(R.drawable.default_pic)
                .into(imageView);*/
    }
}
